<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
      layout:decorator="layouts/main">
<head>
    <meta charset="utf-8"/>
    <meta name="renderer" content="webkit"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>文件预览</title>
</head>

<body>
<div align="center">
    <div id="text_viewer" th:data-fileurl="${fileUrl}"></div>
</div>
<script type="text/javascript" src="/js/jquery.min-1.10.2.js"></script>
<script type="text/javascript">
    $(function() {
        var fileUrl = $("#text_viewer").data("fileurl");

        // https://stackoverflow.com/questions/39758031/get-text-from-a-txt-file-in-the-url
        fetch(fileUrl)
          .then(function(response) {
            response.text().then(function(text) {
              $("#text_viewer").text(text);
            });
          });
    });
</script>
</body>
</html>